/*
 * QStringAdapter.h  0.4.0 / Nov 14, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef QSTRINGADAPTER_H
#define QSTRINGADAPTER_H

#include "Cute4jCommon.h"

// QStringAdapter Class. -------------------------------------------------------

/*!
 * \brief QString Adapter.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT QStringAdapter : public QString
{
public:
  QStringAdapter(JNIEnv *env, jstring str);
public:
  inline QStringAdapter(const QStringAdapter &qsa);
  inline QStringAdapter(const QString &qs);
public:
  jstring toJString(JNIEnv *env);
public:
  inline QStringAdapter &operator=(const QStringAdapter &qsa);
  inline QStringAdapter &operator=(const QString &qs);
  inline QStringAdapter &operator+=(const QStringAdapter &qsa);
  inline QStringAdapter &operator+=(const QString &qs);
public:
  static jstring toJString(JNIEnv *env, const QString &str);
};

// QStringAdapter :: Public Inline Constructors. -------------------------------

/*!
 * \brief Copy constructor. Constructs new QStringAdapter object using the
 *        specified QStringAdapter argument.
 *
 * \param qsa the QStringAdapter argument
 */
inline QStringAdapter::QStringAdapter(const QStringAdapter &qsa)
  : QString(qsa)
{
  // empty body
}

/*!
 * \brief Constructs new QStringAdapter object using the specified QString
 *        argument.
 *
 * \param qs the QString argument
 */
inline QStringAdapter::QStringAdapter(const QString &qs)
  : QString(qs)
{
  // empty body
}

// QStringAdapter :: Public Inline Operators. ----------------------------------

/*!
 * \brief Operator \c = .
 *
 * \param qsa the QStringAdapter argument
 *
 * \return reference to this QStringAdapter object
 */
inline QStringAdapter &QStringAdapter::operator=(const QStringAdapter &qsa)
{
  QString::operator=(qsa);
  return *this;
}

/*!
 * \brief Operator \c = .
 *
 * \param qs the QString argument
 *
 * \return reference to this QStringAdapter object
 */
inline QStringAdapter &QStringAdapter::operator=(const QString &qs)
{
  QString::operator=(qs);
  return *this;
}

/*!
 * \brief Operator \c += .
 *
 * \param qsa the QStringAdapter argument
 *
 * \return reference to this QStringAdapter object
 */
inline QStringAdapter &QStringAdapter::operator+=(const QStringAdapter &qsa)
{
  append(qsa);
  return *this;
}

/*!
 * \brief Operator \c += .
 *
 * \param qs the QString argument
 *
 * \return reference to this QStringAdapter object
 */
inline QStringAdapter &QStringAdapter::operator+=(const QString &qs)
{
  append(qs);
  return *this;
}

// QStringAdapter :: Related Non-Member. ---------------------------------------

/*!
 * \brief Operator \c + .
 *
 * \param qsa1 the first QStringAdapter argument
 * \param qsa2 the second QStringAdapter argument
 *
 * \return QStringAdapter which is the result of concatenating qsa1 and qsa2
 */
inline const QStringAdapter operator+(const QStringAdapter &qsa1,
                                      const QStringAdapter &qsa2)
{
  QStringAdapter tqsa(qsa1);
  tqsa.append(qsa2);
  return tqsa;
}

#endif // QSTRINGADAPTER_H
